package org.csu.mypetstore.web.servlets;

import org.csu.mypetstore.service.AccountService;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

public class UsernameIsRightServlet extends HttpServlet {
    public static final String VIEW_SIGNON = "/WEB-INF/jsp/account/SignonForm.jsp";
    private AccountService service;
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String username = request.getParameter("username");
        System.out.println("psd  "+username);
        service = new AccountService();
        String result = service.passwordIsExist(username);
        response.setContentType("text/plain");
        PrintWriter out = response.getWriter();

        out.print(result);

        out.flush();
        out.close();
    }
}
